package com.twu.biblioteca.model;

import java.io.PrintStream;

/**
 * Created with IntelliJ IDEA.
 * User: cschlumb
 * Date: 06/08/2013
 * Time: 09:24
 * To change this template use File | Settings | File Templates.
 */
public class BookFormatter implements IBookFormatter {

    private final StringBuilder sb;
    private final PrintStream printStream;

    public BookFormatter(PrintStream printStream) {
        this.printStream = printStream;
        sb = new StringBuilder();
    }

    @Override
    public void addBook(Book book) {
        sb.append("Title: ");
        sb.append(book.getName());
        sb.append("\tAuthor: ");
        sb.append(book.getAuthor());
        sb.append("\tUUID: ");
        sb.append(book.getUuid());
        sb.append('\n');
    }

    @Override
    public void print() {
        printStream.println(sb.toString());
    }
}
